// pages/bk/onTime/index.js
Page({
  data: {
    foodList: []
  },

  onChange: function (event) {
    let that = this;
    let foodID = event.currentTarget.dataset.foodid;
    let isSelling = event.currentTarget.dataset.selling;
    wx.request({
      url: 'http://adt.dmxz.com/api/5c0f4378c3b8d',
      data: {
        food_id: foodID,
        is_selling: isSelling
      },
      header: {},
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        console.log(res);
        that.setData({
          foodList: res.data.data.foodList
        });
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  menuTabBarChange: function (options) {
    switch (options.detail.key) {
      case "onTime":
        wx.redirectTo({
          url: '../onTime/index'
        })
        break;
      case "foodList":
        wx.redirectTo({
          url: '../foodList/index'
        })
        break;
      case "order":
        wx.redirectTo({
          url: '../order/index'
        })
        break;
      default: break;
    }
  },
  onLoad: function (options) {
    let that = this;
    wx.request({
      url: 'http://adt.dmxz.com/api/5c0f4136ca289',
      data: '',
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        console.log(res);
        that.setData({
          foodList: res.data.data.foodList
        });
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  onReady: function () {

  },
  onShow: function () {

  },

  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})